#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;

const int kMaxN = 2e5 + 10;

pair<int, int> p[kMaxN];
pair<int, int> s[kMaxN][2];
long long f[kMaxN][2];

bool cmp(const pair<int, int>& lhs, const pair<int, int>& rhs) {
  if (max(lhs.first, lhs.second) != max(rhs.first, rhs.second)) {
    return max(lhs.first, lhs.second) < max(rhs.first, rhs.second);
  } else {
    if (lhs.first != rhs.first) {
      return lhs.first < rhs.first;
    } else {
      return lhs.second > rhs.second;
    }
  }
}

int Dist(const pair<int, int>& lhs, const pair<int, int>& rhs) {
  return abs(lhs.first - rhs.first) + abs(lhs.second - rhs.second);
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int n, lv = 0;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p + 1, p + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    if (max(p[i].first, p[i].second) != max(p[i - 1].first, p[i - 1].second)) {
      s[lv][1] = p[i - 1];
      s[++lv][0] = p[i];
    }
  }
  s[lv][1] = p[n];
  for (int i = 1; i <= lv; i++) {
    // cout << i << ":\n";
    // cout << s[i][0].first << " " << s[i][0].second << "\n";
    // cout << s[i][1].first << " " << s[i][1].second << "\n";
    f[i][0] = min(f[i - 1][0] + Dist(s[i - 1][0], s[i][1]), f[i - 1][1] + Dist(s[i - 1][1], s[i][1])) + Dist(s[i][0], s[i][1]);
    f[i][1] = min(f[i - 1][0] + Dist(s[i - 1][0], s[i][0]), f[i - 1][1] + Dist(s[i - 1][1], s[i][0])) + Dist(s[i][0], s[i][1]);
    // cout << "f[i]:\n";
    // cout << f[i][0] << " " << f[i][1] << '\n';
  }
  cout << min(f[lv][0], f[lv][1]) << "\n";
  return 0;
}